package cn.dapeng.features;

import cn.dapeng.util.SleepingUtil;

import java.util.concurrent.TimeUnit;

public class Volatile_T01 {

    public static /*volatile*/ boolean running = true;


    public static void m() {
        System.out.println("thread started");
        while (running) {

        }
        System.out.println("thread stopped");
    }

    public static void main(String[] args) {

        Thread thread = new Thread(Volatile_T01::m, "t1");

        thread.start();

        SleepingUtil.sleep(1, TimeUnit.SECONDS);

        running = false;
    }
}
